import Main from '@/views/Main.vue';

// 不作为Main组件的子页面展示的页面单独写，如下
export const loginRouter = {
    path: '/login',
    name: 'login',
    meta: {
        title: 'Login - 登录'
    },
    component: resolve => {
        require(['@/views/login.vue'], resolve);
    }
};

export const page404 = {
    path: '/*',
    name: 'error_404',
    meta: {
        title: '404-页面不存在'
    },
    component: resolve => {
        require(['@/views/error_page/404.vue'], resolve);
    }
};

export const page403 = {
    path: '/403',
    meta: {
        title: '403-权限不足'
    },
    name: 'error_403',
    component: resolve => {
        require(['@//views/error_page/403.vue'], resolve);
    }
};

export const page500 = {
    path: '/500',
    meta: {
        title: '500-服务端错误'
    },
    name: 'error_500',
    component: resolve => {
        require(['@/views/error_page/500.vue'], resolve);
    }
};

// 作为Main组件的子页面展示但是不在左侧菜单显示的路由写在otherRouter里
export const otherRouter = {
    path: '/',
    name: 'otherRouter',
    component: Main,
    children: [
        {
            path: 'home',
            title: {i18n: 'home'},
            name: 'home_index',
            component: resolve => {
                require(['@/views/home/home.vue'], resolve);
            }
        },
        {
            path: 'ownspace',
            title: '个人中心',
            name: 'ownspace_index',
            component: resolve => {
                require(['@/views/own-space/own-space.vue'], resolve);
            }
        }
    ]
};

// 作为Main组件的子页面展示并且在左侧菜单显示的路由写在appRouter里
export const appRouter = [
    {
        path: '/setting',
        name: 'setting',
        title: '用户设置',
        component: Main,
        children: [
            {
                path: 'systemUser',
                title: '用户',
                name: 'systemUserIndex',
                component: resolve => {
                    require(['@/views/systemUser/index.vue'], resolve);
                }
            }
        ]
    },
    {
        path: '/statements',
        title: '财务系统管理',
        name: 'statements',
        component: Main,
        children: [
            {
                path: 'index',
                title: '财务系统管理',
                name: 'statementsIndex',
                component: resolve => {
                    require(['@/views/statements/index.vue'], resolve);
                }
            }
        ]
    },
    {
        path: '/project',
        title: '项目信息',
        name: 'project',
        component: Main,
        children: [
            {
                path: 'index',
                title: '项目信息',
                name: 'projectIndex',
                component: resolve => {
                    require(['@/views/project/index.vue'], resolve);
                }
            }
        ]
    }
];

// 所有上面定义的路由都要写在下面的routers里
export const routers = [
    loginRouter,
    otherRouter,
    // preview,
    ...appRouter,
    page500,
    page403,
    page404
];
